layui.use(['table', 'layer', 'jquery'], function () {
    var $ = layui.jquery,
        table = layui.table,
        layer = layui.layer;


    var tableIns = table.render({
        elem: "#bomList",
        url: ctx + "/design/bomSelectByParams",
        cellMinWidth: 95,
        height: "full-125",
        page: true,
        toolbar: "#toolbarDemo",
        cols: [[
            {type: "checkbox", fixed: "center"},
            {type: "numbers"},
            {title: "项目编号", field: "projectNo", templet:function (data){
                return data.projectBean.projectNo;
                }},
            {title: "物料编号", field: "materialNo"},
            {title: "物料名称", field: "materialName"},
            {title: "物料数量", field: "materialCount"},
            {
                title: "物料单位", templet: function (data) {
                    console.log(data.materialBean)
                    if (data.materialBean == null) {
                        return "暂无"
                    } else {
                        return data.materialBean.materialUnit
                    }
                }
            },
        ]]
    })
    /**
     * 搜索
     */

    $(".search_btn").click(function () {
        tableIns.reload({
            where: {
                projectNo: $("[name='projectNo']").val(),
                materialNo: $("[name='materialNo']").val()
            }, page: {
                curr: 1
            }
        })
    })

});